<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>新活动管理</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn btn-default" href="{:U('Activity/add')}">新增模版</a>
        </div>
        <!-- 高级搜索 -->
        <!--        <div class="search-form fr cf">
                    <div class="sleft">
                        <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="请输入活动标题">
                        <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
                    </div>
                </div>-->
    </div>


    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th>模版标题</th>
                <th>模版简码</th>
                <th>页面url</th>
                <th>是否可分享</th>
                <th>创建时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
                        <td><a href="{:U('Activity/edit?id='.$vo['id'])}">{$vo.name}</a></td>
                        <td>{$vo.bin}</td>
                        <td>http://wxshop.guoran100.com/index.php?s=/home/activity/actshare/bin/{$vo.bin}.html</td>
                        <if condition="$vo.share == 1">
                            <td>是</td>
                            <else/>
                            <td>否</td>
                        </if>
                        <td>{$vo.createAt|time_format}</td>
                        <td>{$vo.status_text}</td>

                        <td>
                            <button class="btn btn-primary" type="button" onClick="test(event)">预览</button>
                            <a href="{:U('Activity/del?id='.$vo['id'])}" class="confirm ajax-get btn btn-danger">删除</a>
                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
    <div class="modal fade" id="myModal" tabindex="－1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content" style="margin-top: 100px;width: 302px;">
                <div id="qrcode" ></div>
            </div>
        </div>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>

    <script type="text/javascript">
        function test(event)
        {
            event = event ? event : window.event;
            var obj = event.srcElement ? event.srcElement : event.target;
            $(obj).attr({"disabled":"disabled"});
            var gjz=$("td:eq(2)",$(obj).parents("tr")).text();

            var u =  "http://wxshop.guoran100.com/index.php?s=/home/activity/actshare/bin/"+gjz+".html";
            jQuery('#qrcode').qrcode({width: 300,height: 300,text: u});
            $('#myModal').modal('show');

        }
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });

        //导航高亮
        highlight_subnav('{:U('Activity/index')}');
    </script>
</block>
